package com.skp.shaphan.ui.dialogs;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import com.skp.shaphan.ShaphanApp;
import com.skp.shaphan.ui.buttons.ButtonsPane;
import com.skp.shaphan.ui.buttons.DialogCancelButton;
import com.skp.shaphan.ui.buttons.NavSearchOkButton;

/**
 * This dialog allows a user to search for the navigation to a component
 * @author Stephen Phillips
 *
 */
public class NavigationSearchDialog extends JDialog {
	private JTextField componentName;
	private JTextArea results;
	
	/**
	 * Create the dialog GUI
	 */
	public NavigationSearchDialog() {
		super(ShaphanApp.getMainWindow());
		setTitle("Navigation Search");
		setSize(300, 300);
		
		this.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.gridy = 0;
		
		this.add(new JLabel("Component Name:"), c);
		
		componentName = new JTextField();
		c.weightx = 1.0;
		c.fill = GridBagConstraints.BOTH;
		this.add(componentName, c);
		c.gridy++;
		
		c.fill = GridBagConstraints.NONE;
		this.add(new JLabel("Results:"), c);
		c.weightx = 0;
		c.gridy++;
		results = new JTextArea();
		JScrollPane scroll = new JScrollPane(results);
		c.weightx = 1.0;
		c.weighty = 1.0;
		c.fill = GridBagConstraints.BOTH;
		c.gridwidth = 2;
		this.add(scroll, c);
		
		c.gridy++;
		NavSearchOkButton okButton = new NavSearchOkButton(this);
		this.add(new ButtonsPane(new DialogCancelButton(this), okButton), c);
	}	
	
	public String getComponentName() {
		return componentName.getText();
	}
	
	public void setSearchResults(String results) {
		this.results.setText(results);
	}
}
